#include "dialog.h"
#include <QPixmap>
#

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
{
    username=new QLabel(tr("username"));
    usernameLineEdit= new QLineEdit;
    name=new QLabel(tr("name"));
    nameLineEdit=new QLineEdit;
    sex=new QLabel(tr("sex"));
    sexLineEdit=new QLineEdit;
    department=new QLabel(tr("department"));
    departmentTextEdit=new QTextEdit;
    age=new QLabel(tr("age"));
    ageLineEdit=new QLineEdit;
    other=new QLabel(tr("other"));
    other->setFrameStyle(QFrame::Panel|QFrame::Sunken);
    leftLayout=new QGridLayout();
    leftLayout->addWidget(username,0,0);
    leftLayout->addWidget(usernameLineEdit,0,1);
    leftLayout->addWidget(name,1,0);
    leftLayout->addWidget(nameLineEdit,1,1);
    leftLayout->addWidget(sex,2,0);
    leftLayout->addWidget(sexLineEdit,2,1);
    leftLayout->addWidget(department,3,0);
    leftLayout->addWidget(departmentTextEdit,3,1);
    leftLayout->addWidget(age,4,0);
    leftLayout->addWidget(ageLineEdit,4,1);
    leftLayout->addWidget(other,5,0,1,2); //addWidget(target,int row, int column, int rowSpan, int columnSpan)

    headImage=new QLabel(tr("head Image"));
    headIconLabel=new QLabel;
    QPixmap icon("123.png");
    headIconLabel->setPixmap(icon);
    headIconLabel->resize(icon.width()/2,icon.height()/2);
    upDate=new QPushButton(tr("update"));
    introduceLabel=new QLabel(tr("introduction"));
    introduceTextEdit=new QTextEdit;
    rightLayout=new QVBoxLayout();
    rightLayout->addWidget(headImage);
    rightLayout->addWidget(headIconLabel);
    rightLayout->addWidget(upDate);
    rightLayout->addWidget(introduceLabel);
    rightLayout->addWidget(introduceTextEdit);

    OkBtn=new QPushButton(tr("Ok"));
    CancelBtn=new QPushButton(tr("Cancel"));
    ButtonLayout=new QHBoxLayout();
    ButtonLayout->addStretch();
    ButtonLayout->addWidget(OkBtn);
    ButtonLayout->addWidget(CancelBtn);

    QGridLayout *mainLayout=new QGridLayout(this);
    mainLayout->setMargin(15);
    mainLayout->setSpacing(10);
    mainLayout->addLayout(leftLayout,0,0);
    mainLayout->addLayout(rightLayout,0,1);
    mainLayout->addLayout(ButtonLayout,1,0,1,2);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);

    inputBtn=new QPushButton(tr("input Dialog"));
    mainLayout->addWidget(inputBtn,3,0);
    connect(inputBtn,SIGNAL(clicked(bool)),this,SLOT(ShowInputDlg()));
}

void Dialog::ShowInputDlg()
{
    inputDlg=new InputDlg(this);
    inputDlg->show();
}

Dialog::~Dialog()
{

}
